<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title></title>
	</head>
	<body>
		<div id="" style="margin-left: 700px;">
		<select name="xiala" id="xiala" style="margin-left: 25px;" >
			<option value="0">选择大小</option>
			<option value ="1">大</option>
			<option value ="2">小</option>
		</select>
		<br>
		<img src="img/saizi/1.jpg" id="img222" >
		<br>
		<br>
		<button type="button" style="margin-left: 30px;" onclick="sz()" >开始</button>
		</div>
</body>
	<script type="text/javascript">
		var img222=document.getElementById('img222');
		var select=document.getElementById('xiala');
		
		//创建数组存放图片
		var img_sz=["img/saizi/1.jpg","img/saizi/2.jpg","img/saizi/3.jpg",
					"img/saizi/4.jpg","img/saizi/5.jpg","img/saizi/6.jpg"]
					
		
		var num=0; 
		
		function sz(){
		if (select.value=="0") {
			alert('请选择大小');
			return false;
			}
		var myInerterval = setInterval(function (){
			//创建随机数
			var randNum=Math.floor(Math.random()*img_sz.length);
				img222.src=img_sz[randNum];
				num++;
				if(num>10){
					clearInterval(myInerterval);
					if(select.value=="1"){
						if(img_sz[randNum]>img_sz[3]){
							alert('猜对了');
						}
						else{
							alert('猜错了');
						}
					};
					if(select.value=="2"){
						if(img_sz[randNum]>img_sz[3]){
							alert('猜错了');
						}
						else{
							alert('猜对了');
						}
					}
				}
				
			},200)
		
		
		
		
		
		
		
		}
			
			
	</script>
</html>








